package cn.com.headfree.mouldshow.service.impl;

import cn.com.headfree.mouldshow.dao.UserDataInfoDao;
import cn.com.headfree.mouldshow.service.UserDataInfoService;
import cn.com.headfree.vo.BusinessIdsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;


@Service("userDataInfoService")
public class UserDataInfoServiceImpl implements UserDataInfoService {
	@Autowired
	private UserDataInfoDao userInfoDao;

	/**
	 * 组合各类型ID，以下载附件
	 * @param erpNo
	 * @return
	 */
	@Override
	public List<BusinessIdsVo> getBusinessIdByErpNo(String erpNo) {
		List<BusinessIdsVo> list = new ArrayList<>();
		//基本信息
		BusinessIdsVo baseId = userInfoDao.getBaseInfoByErpNo(erpNo);
		if(baseId != null){
			baseId.setTypeName("基本信息");
			list.add(baseId);
		}

		//学历
		List<BusinessIdsVo> eduIds = userInfoDao.getEducateInfoByErpNo(erpNo);
		if(eduIds != null && eduIds.size() > 0){
			for (BusinessIdsVo eduId:eduIds){
				eduId.setTypeName("学历信息");
				list.add(eduId);
			}
		}

		//教育培训授课
		List<BusinessIdsVo> studyIds = userInfoDao.getContiStudyInfoByErpNo(erpNo);
		if(studyIds != null && studyIds.size() > 0){
			for (BusinessIdsVo studyId:studyIds){
				studyId.setTypeName("教育培训及授课经历");
				list.add(studyId);
			}
		}

		//个人荣誉
		List<BusinessIdsVo> honnorIds = userInfoDao.getHonnorInfoByErpNo(erpNo);
		if(honnorIds != null && honnorIds.size() > 0){
			for (BusinessIdsVo honnorId:honnorIds){
				honnorId.setTypeName("个人荣誉");
				list.add(honnorId);
			}
		}

		//专业竞赛考试
		List<BusinessIdsVo> conIds = userInfoDao.getContestInfoByErpNo(erpNo);
		if(conIds != null && conIds.size() > 0){
			for (BusinessIdsVo conId:conIds){
				conId.setTypeName("专业竞赛考试");
				list.add(conId);
			}
		}

		//专家人才称号
		List<BusinessIdsVo> expertIds = userInfoDao.getExpertTitleInfoByErpNo(erpNo);
		if(expertIds != null && expertIds.size() > 0){
			for (BusinessIdsVo expertId:expertIds){
				expertId.setTypeName("专家人才称号");
				list.add(expertId);
			}
		}

		//专业技术资格
		List<BusinessIdsVo> proIds = userInfoDao.getProTecInfoByErpNo(erpNo);
		if(proIds != null && proIds.size() > 0){
			for (BusinessIdsVo proId:proIds){
				proId.setTypeName("专业技术资格");
				list.add(proId);
			}
		}

		//技能等级
		List<BusinessIdsVo> skillIds = userInfoDao.getSkillLevelInfoByErpNo(erpNo);
		if(skillIds != null && skillIds.size() > 0){
			for (BusinessIdsVo skillId:skillIds){
				skillId.setTypeName("技能等级");
				list.add(skillId);
			}
		}

		//师带徒信息
		List<BusinessIdsVo> tutorIds = userInfoDao.getTSdtTutorPrentInfoByErpNo(erpNo);
		if(tutorIds != null && tutorIds.size() > 0){
			for (BusinessIdsVo tutorId:tutorIds){
				tutorId.setTypeName("导师带徒");
				list.add(tutorId);
			}
		}

		//学术成果
		List<BusinessIdsVo> acadeIds = userInfoDao.getAcadeAchiveInfoByErpNo(erpNo);
		if(acadeIds != null && acadeIds.size() > 0){
			for (BusinessIdsVo acadeId:acadeIds){
				acadeId.setTypeName("学术成果");
				list.add(acadeId);
			}
		}

		//标准制定
		List<BusinessIdsVo> standIds = userInfoDao.getStandInfoByErpNo(erpNo);
		if(standIds != null && standIds.size() > 0){
			for (BusinessIdsVo standId:standIds){
				standId.setTypeName("标准制定");
				list.add(standId);
			}
		}

		//发明专利
		List<BusinessIdsVo> patentIds = userInfoDao.getPatentInfoByErpNo(erpNo);
		if(patentIds != null && patentIds.size() > 0){
			for (BusinessIdsVo patentId:patentIds){
				patentId.setTypeName("发明专利");
				list.add(patentId);
			}
		}

		//技艺革新
		List<BusinessIdsVo> tecIds = userInfoDao.getTecInnovInfoByErpNo(erpNo);
		if(tecIds != null && tecIds.size() > 0){
			for (BusinessIdsVo tecId:tecIds){
				tecId.setTypeName("技艺革新");
				list.add(tecId);
			}
		}

		//科技创新
		List<BusinessIdsVo> tecManIds = userInfoDao.getTecManInnovByErpNo(erpNo);
		if(tecManIds != null && tecManIds.size() > 0){
			for (BusinessIdsVo tecManId:tecManIds){
				tecManId.setTypeName("科技管理创新");
				list.add(tecManId);
			}
		}

		//项目课题成果
		List<BusinessIdsVo> projIds = userInfoDao.getProjAchieveInfoByErpNo(erpNo);
		if(projIds != null && projIds.size() > 0){
			for (BusinessIdsVo projId:projIds){
				projId.setTypeName("项目课题成果");
				list.add(projId);
			}
		}

		//挂职轮岗
		List<BusinessIdsVo> rotIds = userInfoDao.getRotationInfoByErpNo(erpNo);
		if(rotIds != null && rotIds.size() > 0){
			for (BusinessIdsVo rotId:rotIds){
				rotId.setTypeName("挂职轮岗");
				list.add(rotId);
			}
		}

		return list;
	}


}
